package com.cdtye.shuoh.config.gb28181.bean;


import lombok.Data;
import org.jetbrains.annotations.NotNull;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Description:设备录像bean 
 * @author: swwheihei
 * @date:   2020年5月8日 下午2:06:54     
 */
@ConditionalOnProperty(value = "sip.enabled", havingValue = "true")
@Data
public class RecordItem  implements Comparable<RecordItem>{

	private String deviceId;
	
	private String name;
	
	private String filePath;

	private String fileSize;
	
	private String address;
	
	private String startTime;
	
	private String endTime;
	
	private int secrecy;
	
	private String type;
	
	private String recorderId;
	@Override
	public int compareTo(@NotNull RecordItem recordItem) {
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		try {
			Date startTime_now = sdf.parse(startTime);
			Date startTime_param = sdf.parse(recordItem.getStartTime());
			if (startTime_param.compareTo(startTime_now) > 0) {
				return -1;
			}else {
				return 1;
			}
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return 0;
	}
}
